package com.yupi.yuaicodemother.utils;


import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.json.JSONUtil;

/**
 * 缓存Key生成工具
 */
public class CacheKeyUtils {

    public static String generateKey(Object obj){
        if(obj == null){
            return DigestUtil.md5Hex("null");
        }
        // 先转JSON,再转MD5
        String jsonStr = JSONUtil.toJsonStr(obj);
        return DigestUtil.md5Hex(jsonStr);
    }
}
